package com.api.organization.getorganization;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.test.context.ContextConfiguration;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

import com.api.test.AbstractApiTest;
import com.zyncro.api.IOrganizationApiService;
import com.zyncro.api.exceptions.ZyncroApiException;
import com.zyncro.api.model.ObjectResultApi;
import com.zyncro.api.model.OrganizationApi;

@ContextConfiguration(locations = { "classpath:/organization/organization-context.xml" })
public class GetOrganization extends AbstractApiTest {

	@Value("#{org_editOrganization[administrator].appId}")
	private String userId;

	@Value("#{org_editOrganization[administrator].password}")
	private String userPassword;

	@Value("#{org_editOrganization.name}")
	private String organizationName;

	@BeforeClass
	public void setUpVariables() {

		getApi().login(userId, userPassword);
	}

	@Test
	public synchronized void testAddUser() throws ZyncroApiException {

		ObjectResultApi<OrganizationApi> result = getApi().getService(IOrganizationApiService.class).getOrganization();

		OrganizationApi org = result.getObject();

		Assert.assertEquals(org.getName(), organizationName, "Organization name");
	}
}
